<template>
	<view>
		<Navbar :backUrl="'mine'"></Navbar>
		<view class="u-m-20">
			<TeaList :list="teaList" :isPoint="true" @goPointDetail="goPointDetail"></TeaList>
		</view>
		<Loadmore :status="status"></Loadmore>
		<view style="height: 200rpx;"></view>
		<Bottom :isReturn="true" :backUrl="'mine'" @confirm="confirm"></Bottom>
	</view>
</template>

<script>
	import Navbar from '@/components/Navbar.vue'
	import Bottom from '@/components/Bottom.vue'
	import TeaList from '@/components/TeaList.vue'
	import Loadmore from '@/components/Loadmore.vue'
	import reachBottom from '@/mixins/reachBottom.js'
	import { teaEvaluateList, teaList } from '@/network/tea.js'
	import { formatDistance, pointTransform } from '@/utils/index.js'
	export default{
		mixins: [reachBottom],
		components:{
			Navbar,
			Bottom,
			TeaList,
			Loadmore
		},
		data(){
			return{
				teaList:[],
				status: 'loadmore',
				user_id: uni.getStorageSync("user_id")
			}
		},
		onLoad(){
			this.getPointList()
		},
		methods:{
			getPointList(){
				uni.showLoading({
					title: "加载中"
				})
				const params = {
					page: this.page,
					limit: this.pageSize,
					user_id: this.user_id,
					type: 3
				}
				teaList(params).then(res=>{
					if(res.data.list.length > 0){
						res.data.list.map(item=>{
							switch(item.pay_type){
								case 1:
								    item.pay_name = '免费'
									break;
								case 2:
								    item.pay_name = `${parseInt(item.price)}`
									break;
								case 3:
								    item.pay_name = `${parseInt(item.price)}积分`
									break;
							}
							item.user.number = pointTransform(item.user.number)
							item.distance = formatDistance(item.distance)
							this.teaList.push(item)
						})
					}
					if(res.data.list.length < 10) this.status = 'nomore'
					uni.hideLoading()
				})
			},
			goPointDetail(data){
				const params = {	
					id: data.teaId,
					type: (this.user_id == data.id) ? 1: 2
				}
				uni.navigateTo({
					url: "/teaBureau/teaExamine/teaExamine?data=" + JSON.stringify(params)
				})
			},
			loadData() {
				if(this.status == 'nomore') return
				this.page++
				this.status = 'loading'
				this.getPointList()
			}
		}
	}
</script>

<style>
</style>